package starter.kit.rx.app.feature.book;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;

import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import nucleus.factory.RequiresPresenter;
import starter.kit.feature.StarterFragConfig;
import starter.kit.feature.rx.RxStarterRecyclerFragment;
import starter.kit.rx.app.R;
import starter.kit.rx.app.model.bean.book.Books;

/**
 * ============================================================
 * 版权： xx 版权所有（c）2016
 * <p>
 * 作者：Loofer
 * 版本：1.0
 * 创建日期 ：2016/10/25 10:01.
 * 描述：
 * <p>
 * 注:如果您修改了本类请填写以下内容作为记录，如非本人操作劳烦通知，谢谢！！！
 * Modified Date Modify Content:
 * <p>
 * ==========================================================
 */
@RequiresPresenter( BookReadingPresenter.class)
public class BookReadingFragment extends RxStarterRecyclerFragment {

    public static BookReadingFragment newInstance(int position, String title) {
        Bundle args = new Bundle();
        args.putString("title", title);
        args.putInt("position", position);
        BookReadingFragment fragment = new BookReadingFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);

        StarterFragConfig.Builder builder = new StarterFragConfig.Builder()
                .withIdentifierRequest(false)
                .pageSize(10)
                .loadingTriggerThreshold(0)
                .bind(Books.class, BookViewHolder.class)
                .recyclerLayoutManager(new GridLayoutManager(getActivity(), 3))
                .recyclerViewDecor(new HorizontalDividerItemDecoration
                        .Builder(getContext()).size(10)
                        .colorResId(R.color.dividerColor)
                        .build())
                .swipeRefreshLayoutColors(Color.BLUE, Color.GREEN, Color.RED, Color.YELLOW);

        buildFragConfig(builder.build());
    }
}
